package priv.lhy.feign.configuration;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: lihy
 * date: 2019/10/31 10:35
 * description: 配置ribbon负载算法，如果被@ComponentScan扫描到则所有rabbonClient的负载算法都会改变
 * 若要自定义某个rabbonClient算法，则要将configuration类配置在@ComponentScan扫描不到的包中，
 * 然后在需要使用的rabbonClient上加上 @RibbonClient(name = "...", configuration = RibbonConfiguration
 * .class)
 */
@Configuration
public class RibbonConfiguration {

    @Bean
    public IRule getRibbonRule(){
        return new RandomRule();
    }
}
